package com.tanhua.model.vo;

import com.tanhua.model.domain.UserInfo;
import com.tanhua.model.mongo.UserLike;
import com.tanhua.model.mongo.Visitors;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class FriendVo implements Serializable {

    private Integer id; //编号
    private String avatar; //用户头像
    private String nickname; //昵称
    private String gender; //性别
    private Integer age; //年龄
    private String city; //城市
    private String education; //学历
    private Integer marriage; //婚姻状态（0未婚，1已婚）

    private Integer matchRate; //匹配度
    private boolean alreadyLove; //是否喜欢ta

    public static FriendVo init(UserInfo userInfo, Visitors visitors, UserLike userLike) {
        FriendVo vo = new FriendVo();
        BeanUtils.copyProperties(userInfo,vo);
        vo.setId(Integer.valueOf(String.valueOf(userInfo.getId())));
        if(visitors != null) {
            vo.setMatchRate(visitors.getScore().intValue());
        }
        if (userLike != null){
            vo.setAlreadyLove(userLike.getIsLike());
        }

        return vo;
    }
}